﻿using GraphDrawing2.Canvas;
using GraphDrawing2.V2.Graph.Model;

namespace GraphDrawing2.V2.Concrete.Model
{
    public class Model2
    {
        public CanvasModel CanvasModel { get; private set; }
        public ViewPortModel ViewPort { get; private set; }
        public ElementsModel ElementsModel { get; private set; }
        public ICanvasView View { get; private set; }
        public IHitTestResult HitTest { get; private set; }

        public Model2(CanvasModel canvasModel, ElementsModel elements, ICanvasView view)
        {
            CanvasModel = canvasModel;
            ViewPort = canvasModel.ViewPort;
            ElementsModel = elements;
            View = view;
        }

        public void UpdateHitTest()
        {
            var position = CanvasModel.MousePosition;
            var worldPosition = ViewPort.ToWorld(position);
            HitTest = ElementsModel.HitTest(worldPosition);
        }
    }
}